package treedummy;


import java.util.ArrayList;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;




@ManagedBean
@SessionScoped
public class ListBean
{
	private ArrayList<Node> tree;

	private ArrayList<Node> generateTree(){
		ArrayList<Node> nlist = new ArrayList<Node>();
		Node n = new Node();
		n.setName("root");
		Node n1 = new Node(n);
		n1.setName("folder1");
		Node n2 = new Node(n);
		n2.setName("folder2");
		Node n3 = new Node(n);
		n3.setName("folder3");
		Node n4 = new Node(n1);
		n4.setName("folder4");
		Leaf l1 = new Leaf(n1);
		l1.setContent("nyestfenyo");
		Leaf l2 = new Leaf(n4);
		l2.setContent("buzamezo");
		Leaf l3 = new Leaf(n4);
		l3.setContent("buzamezo2");
		Leaf l4 = new Leaf(n2);
		l4.setContent("buzamezo");
		Leaf l5 = new Leaf(n3);
		l5.setContent("kendermezo");
		Leaf l6 = new Leaf(n3);
		l6.setContent("buzafenyo");
		Node n5 = new Node(n3);
		n5.setName("folder5");
		Leaf l7 = new Leaf(n5);
		l7.setContent("mar meguntam a neveket");
		nlist.add(n);
		nlist.add(n1);
		nlist.add(n2);
		nlist.add(n3);
		nlist.add(n4);
		nlist.add(n5);
		nlist.add(l1);
		nlist.add(l2);
		nlist.add(l3);
		nlist.add(l4);
		nlist.add(l5);
		nlist.add(l6);
		nlist.add(l7);
		return nlist;
	}

	public ArrayList<Node> getTree()
	{
		if(tree == null)
			tree = generateTree();
		return tree;
	}

	public void setTree(ArrayList<Node> tree)
	{
		this.tree = tree;
	}
	
	
	
}
